/**
 * 
 */
package controller;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Date;
import java.util.Vector;

import model.Anhaenger;
import query.AnhaengerSuchenQuery;

/**
 * @author ldonker
 * 
 */
public class ControllerAnhaenger {

	public static  Vector<Anhaenger> getData(Date startDate, Date endDate, int anhaengertyp) {
		try {
			//Socket erstellen
			Socket socket = new Socket("20.49.184.100", 5550);
			
			//Outputstream erstellen
			ObjectOutputStream clientOutputStream = new ObjectOutputStream(socket.getOutputStream());
			//Inputstream erstellen
			ObjectInputStream clientInputStream = new ObjectInputStream(socket.getInputStream());
			
			//Controller KundeSuchenQuery erstellen
			AnhaengerSuchenQuery as = new AnhaengerSuchenQuery();
			
			as.setVonZeitraum(startDate);
			as.setBisZeitraum(endDate);
			as.setAnhaengertyp(anhaengertyp);
			
			//Controller Objekt an Server senden
			clientOutputStream.writeObject(as);
			System.out.println("ControllerAnhaengerSuchen: AnheangerSuchenQuerry Objekt an Server gesendet");
	
			//Antwort von Server erhalten
			Object inputObj = clientInputStream.readObject();
			System.out.println("ControllerAnhaengerSuchen: Anheanger Objekt von Server erhalten");
			Vector<Anhaenger> vector = (Vector<Anhaenger>) inputObj;
			return vector;
		} catch (Exception e) {
			e.getStackTrace();
		}
		return null;
	}

}
